//定义仓库
import { legacy_createStore as createStore } from 'redux';
import userReducer from './modules/user';

// 数据持久化
import { persistStore, persistReducer } from "redux-persist";
import storage from 'redux-persist/lib/storage'

// 数据持久化:是指页面刷新后，数据仍然能够保持原来的状态
const persistConfig = {
    key: 'myroot',
    storage,
    // whitelist: ['CityReducers'] // 设置某个reducer数据持久化.whitelist:白名单；blacklist:黑名单
}

const persistedReducer = persistReducer(persistConfig, userReducer)


const store = createStore(persistedReducer, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__())
let persistor = persistStore(store)
export {
    persistor,
    store
}